package org.powernode.spring6.service;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

@Service("securityAspect")
@Aspect
@Order(2)
public class SecurityAspect {
    @Before("org.powernode.spring6.service.AspectPoint.common()")
    public void before() {
        System.out.println("前置通知：安全...");
    }

    //后置通知
    @AfterReturning("org.powernode.spring6.service.AspectPoint.common()")
    public void afterReturningAdvice() {
        System.out.println("后置通知：安全...");
    }

    //环绕通知
    @Around("org.powernode.spring6.service.AspectPoint.common()")
    public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕：安全...");
        joinPoint.proceed();
        System.out.println("后环绕：安全...");
    }

    @AfterThrowing("org.powernode.spring6.service.AspectPoint.common()")
    public void afterThrowingAdvice() {
        System.out.println("异常通知：安全...");
    }

    //最终通知
    @After("org.powernode.spring6.service.AspectPoint.common()")
    public void afterAdvice() {
        System.out.println("最终通知：安全...");
    }
}
